package com.huike.clues.service.impl;

import com.huike.clues.domain.SysDictData;
import com.huike.clues.mapper.SysDictDataMapper;
import com.huike.clues.service.ISysDictDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class SysDictDataServiceImpl implements ISysDictDataService {
    @Autowired
    private SysDictDataMapper sysDictDataMapper;
    @Override
    public List<SysDictData> getDictDataByType(String dictType) {
        List<SysDictData> dictDataByType = sysDictDataMapper.getDictDataByType(dictType);

        return dictDataByType;
    }

    @Override
    public List<SysDictData> list(SysDictData sysDictData) {
        List<SysDictData> list = sysDictDataMapper.list(sysDictData);
        return  list;
    }

    @Override
    public void add(SysDictData sysDictData) {
        sysDictData.setCreateTime(LocalDateTime.now());
        sysDictDataMapper.add(sysDictData);
    }


    @Override
    public SysDictData getDetailsById(Long dictCode) {
        return  sysDictDataMapper.getDetailsById(dictCode);
    }


    @Override
    public void update(SysDictData sysDictData) {
        sysDictData.setUpdateTime(LocalDateTime.now());
        sysDictData.setUpdateBy(sysDictData.getUpdateBy());
        sysDictDataMapper.update(sysDictData);
    }


    @Override
    public void deleteByIds(Long[] dictCodes) {
         sysDictDataMapper.deleteByIds(dictCodes);
    }
}
